// stl find/find_if/std::bind/std::placeholders
#include <bits/stdc++.h>
using namespace std;

class Item {
 public:
  std::string name;
  int count;
  Item(std::string id, int count) : name(id), count(count) {}
  bool operator==(const Item &other) const { return this->name == other.name; }
};

struct People {
 public:
  std::string name;
  int count;
  People(std::string c, int n) {
    name = c;
    count = n;
  }
  bool operator==(const People &other) const {
    return this->name == other.name;
  }
};

bool comp(People &p1, std::string name) { return p1.name == name; }

// 0 1 5 6
void test_find() {
  std::vector<People> vtPeople = {{"xi", 3}, {"da", 4}};
  std::vector<People>::iterator it1 =
      std::find_if(vtPeople.begin(), vtPeople.end(),
                   std::bind(comp, std::placeholders::_1, "xi"));
  std::vector<People>::iterator it2 =
      std::find(vtPeople.begin(), vtPeople.end(), People("da", 0));
  printf("it1=%d, it2=%d\n", it1->old, it2->old);
}

int main() {
  test_find();
  return 0;
}
